package server.ejb.beans;

import java.io.Serializable;

import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToOne;

@Entity
@NamedQueries({
@NamedQuery(name="Fluggesellschaft.findByName", query = "SELECT f FROM Fluggesellschaft f WHERE f.name = name"),	
@NamedQuery(name = "Fluggesellschaft.findAll", query = "SELECT f FROM Fluggesellschaft f")})
public class Fluggesellschaft implements Serializable {

	private static final long serialVersionUID = 1L;

	@Id
	@GeneratedValue
	private int fluggesellschaftId;
	@Basic
	private String name;
	@Basic
	private String strasse;
	@Basic
	private int hausnummer;
	@Basic
	private int plz;
	@Basic
	private String stadt;
	@OneToOne(cascade = CascadeType.ALL)
	private Konto konto;

	public int getFluggesellschaftId() {
		return fluggesellschaftId;
	}

	public void setFluggesellschaftId(int fluggesellschaftId) {
		this.fluggesellschaftId = fluggesellschaftId;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getStrasse() {
		return strasse;
	}

	public void setStrasse(String strasse) {
		this.strasse = strasse;
	}

	public int getHausnummer() {
		return hausnummer;
	}

	public void setHausnummer(int hausnummer) {
		this.hausnummer = hausnummer;
	}

	public int getPlz() {
		return plz;
	}

	public void setPlz(int plz) {
		this.plz = plz;
	}

	public String getStadt() {
		return stadt;
	}

	public void setStadt(String stadt) {
		this.stadt = stadt;
	}

	public Konto getKonto() {
		return konto;
	}

	public void setKonto(Konto konto) {
		this.konto = konto;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + fluggesellschaftId;
		result = prime * result + hausnummer;
		result = prime * result + ((konto == null) ? 0 : konto.hashCode());
		result = prime * result + ((name == null) ? 0 : name.hashCode());
		result = prime * result + plz;
		result = prime * result + ((stadt == null) ? 0 : stadt.hashCode());
		result = prime * result + ((strasse == null) ? 0 : strasse.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Fluggesellschaft other = (Fluggesellschaft) obj;
		if (fluggesellschaftId != other.fluggesellschaftId)
			return false;
		if (hausnummer != other.hausnummer)
			return false;
		if (konto == null) {
			if (other.konto != null)
				return false;
		} else if (!konto.equals(other.konto))
			return false;
		if (name == null) {
			if (other.name != null)
				return false;
		} else if (!name.equals(other.name))
			return false;
		if (plz != other.plz)
			return false;
		if (stadt == null) {
			if (other.stadt != null)
				return false;
		} else if (!stadt.equals(other.stadt))
			return false;
		if (strasse == null) {
			if (other.strasse != null)
				return false;
		} else if (!strasse.equals(other.strasse))
			return false;
		return true;
	}

}